<?php
/**
 * 资源介绍页
 * @version 2018-1-16 Added.
 * @version 2018-1-25 sochishun 新增打印界面
 */
// 引入头文件
include './pts_head.php';

// 浏览器输入参数
$path = input('path');
$print = input('print');
if (!$path) {
    exit;
}
$title = basename($path);
$screenshot_path = $path . '/screenshot/0.screenshot.png';
?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title><?php echo $title, ' - 软件介绍' ?></title>
        <style type="text/css">
            body{font-size:12px; color:#333;}
            h1 { border-bottom:solid 1px #CCC; margin-bottom:10px; padding-bottom:10px;}
            h1 a { font-size:12px; font-weight: normal; margin-left:10px;}
            table {border:solid 1px #CCC; border-top:none;border-left:none;}
            th, td{border:solid 1px #CCC; border-bottom:none;border-right:none; padding:5px 10px;}
            tr:nth-child(odd) {background-color:#efefef;}
            a { text-decoration: none; color:#06C}
            .screenshot_img { max-width:600px; max-height:600px; margin-bottom: 10px; border:solid 1px #CCC; }
            .preview_img { max-width:200px; max-height:200px;}
            /* http://papermashup.com/pretty-css3-buttons/ */
            .btn, .btn:visited { background-color: #222; display: inline-block; padding: 5px 10px 6px; color: #fff; text-decoration: none; -moz-border-radius: 6px; -webkit-border-radius: 6px; -moz-box-shadow: 0 1px 3px rgba(0,0,0,0.6); -webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.6); text-shadow: 0 -1px 1px rgba(0,0,0,0.25); border-bottom: 1px solid rgba(0,0,0,0.25); position: relative; cursor: pointer }
            .btn_pink, .btn_pink:visited { background-color: #e22092; }
            .btn_pink:hover { background-color: #c81e82; }
            .btn_green, .btn_green:visited { background-color: #91bd09; }
            .btn_green:hover { background-color: #749a02; }
            .btn_red, .btn_red:visited { background-color: #e62727; }
            .btn_red:hover { background-color: #cf2525; }
            .btn_orange, .btn_orange:visited { background-color: #ff5c00; }
            .btn_orange:hover { background-color: #d45500; }
            .btn_blue, .btn_blue:visited { background-color: #2981e4; }
            .btn_blue:hover { background-color: #2575cf; }
            .btn_yellow, .btn_yellow:visited { background-color: #ffb515; }
            .btn_yellow:hover { background-color: #fc9200; }
        </style>
    </head>
    <body>
        <?php
        echo '<h1>', $title;
        if (!$print) {
            echo '<a href="?path=', $path, '&print=1" target="_blank">[打印]</a>';
        }
        echo '</h1>';
        if (!$print) {
            ?>
            <section>
                <a href="<?php echo $screenshot_path ?>" target="_blank"><img class="preview_img" src="<?php echo $screenshot_path ?>" alt="" /></a>
                <?php
                if (is_file($path . '/git.txt')) {
                    echo '<div style="color:#06C">GIT: ', file_get_contents($path . '/git.txt'), '</div>';
                }
                ?>
                <h3>下载地址</h3>
                <div style="line-height: 21px;">
                    <?php
                    $files = FileUtil::scandirReturn($path . '/asset/', 0, true);
                    foreach ($files as $file) {
                        $filepath = $file['path'];
                        if (is_file($filepath)) {
                            echo '<a href="', $filepath, '">', basename($filepath), '</a> (大小:', FileUtil::formatBytes(filesize($filepath)), ', 更新时间: ', date('Y-m-d H:i:s', filemtime($filepath)), ')<br />';
                        }
                    }
                    ?>
                </div>
            </section>
        <?php } ?>
        <section>
            <h3>软件简介</h3>
            <div class="content">
                <?php
                echo file_get_contents($path . '/intro.txt');
                ?>
            </div>
        </section>
        <section>
            <h3>截图预览</h3>
            <div class="content">
                <?php
                // 说明: 截图名称加序号前缀可以自动排序
                $files = FileUtil::scandirReturn($path . '/screenshot/', 0, true);
                foreach ($files as $file) {
                    $path = $file['path'];
                    if (is_file($path)) {
                        echo '<img src="', $path, '" alt="" class="screenshot_img" /><br />';
                    }
                }
                ?>
            </div>
        </section>
        <?php
        if ($print) {
            echo '<script>window.print()</script>';
        }
        ?>
    </body>
</html>
